<?php defined('_JEXEC') or die('Restricted access'); ?>
<form action="" method="post" name="adminForm">

<table>
<tr>
	<td align="left" width="100%">
		<?php echo JText::_( 'Filter' ); ?>:
		<input type="text" name="search" id="search" value="<?php echo htmlspecialchars($this->lists['search']);?>" class="text_area" onchange="document.adminForm.submit();" />
		<button onclick="this.form.submit();"><?php echo JText::_( 'Go' ); ?></button>
		<button onclick="document.getElementById('search').value='';this.form.getElementById('pid_cid').value='';this.form.getElementById('c_id').value='';this.form.submit();"><?php echo JText::_( 'Filter Reset' ); ?></button>
	</td>
	<td nowrap="nowrap">
			<select name='pid_cid' id='pid_cid' class='inputbox' size='1' onchange="document.adminForm.submit();">
			<option value=''><?php echo JText::_( 'Select a House' ) ?></option>
			<?php $last_p_id = 0 ?>
			<?php foreach($this->lists['houses'] as $house): ?>
			<?php if($last_p_id != $house->p_id): ?>
			<option value="<?php echo $house->p_id ?>" <?php if($house->p_id == $this->pid_cid) echo " selected='selected' " ?>><?php echo $house->p_name ?></option>
			<?php endif; ?>
			<?php $last_p_id = $house->p_id ?>
			<option value='<?php echo $house->p_id . ":" . $house->c_id ?>' <?php if(($house->p_id . ":" . $house->c_id) == $this->pid_cid) echo " selected='selected' " ?> >|__<?php echo $house->c_name?></option>
			<?php endforeach; ?>
			</select>
	</td>
</tr>
</table>


<div id="editcell">
	<table class="adminlist">
	<thead>
		<tr>
			<th width="5">
				<?php echo JText::_( 'ID' ); ?>
			</th>
			<th width="20">
				<input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $this->items ); ?>);" />
			</th>			
			<th>
				<?php echo JText::_( 'Username' ); ?>
			</th>
			<th>
				<?php echo JText::_( 'Name' ); ?>
			</th>
			<th>
				<?php echo JText::_( 'Email' ); ?>
			</th>
		</tr>
	</thead>
	<?php
	$k = 0;
	
	for ($i=0, $n=count( $this->items ); $i < $n; $i++)	{
		$row = &$this->items[$i];
		$checked 	= JHTML::_('grid.id',   $i, $row->id );
		$link 		= JRoute::_( 'index.php?option=com_congregation&controller=profile&task=edit&cid[]='. $row->id );
		?>
		<tr class="<?php echo "row$k"; ?>">
			<td>
				<?php echo $row->id; ?>
			</td>
			<td>
				<?php echo $checked; ?>
			</td>
			<td>
				<a href="<?php echo $link ?>" onclick="return listItemTask('cb<?php echo $i; ?>', 'edit')">
				<?php echo $row->username ; ?>
				</a>
			</td>
			<td>
				<?php echo "<b>" . $row->lname . "</b> " . $row->fname; ?>
			</td>
			<td>
				<?php echo $row->email ; ?>
			</td>
		</tr>
		<?php
		$k = 1 - $k;
	}
	?>
	</table>
	
	<?php echo $this->pagination->getListFooter(); ?>
	
</div>

<input type="hidden" name="option" value="com_congregation" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="c_id" value="<?php echo $this->c_id ?>"/>
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="controller" value="profile" />
</form>
